-- Additional Plugins
lvim.plugins = {
  -- 主题
  { "ellisonleao/gruvbox.nvim" },
  { 'rose-pine/neovim', name = 'rose-pine' },
  { "Mofiqul/dracula.nvim" },
  { "sainnhe/gruvbox-material" },
  { "pineapplegiant/spaceduck" },
  { "folke/tokyonight.nvim" },
  { "rebelot/kanagawa.nvim" },
  { "luisiacc/gruvbox-baby" },

  {
    "stevearc/oil.nvim",
    opts = {
      keymaps = {
        ["g?"] = "actions.show_help",
        ["<CR>"] = "actions.select",
        ["<C-s>"] = "actions.select_vsplit",
        ["<C-h>"] = "actions.select_split",
        ["<C-t>"] = "actions.select_tab",
        ["<C-p>"] = "actions.preview",
        ["<C-c>"] = "actions.close",
        ["<C-l>"] = "actions.refresh",
        ["-"] = "actions.parent",
        ["_"] = "actions.open_cwd",
        ["`"] = "actions.cd",
        ["~"] = "actions.tcd",
        ["gs"] = "actions.change_sort",
        ["gx"] = "actions.open_external",
        ["g."] = "actions.toggle_hidden",
      },
    },
    keys = {
      {"-", "<cmd>Oil<CR>", mode = "n", desc = "oil file"},
    }
  },

  -- 快速跳转
  {
    "folke/flash.nvim",
    event = "VeryLazy",
    opts = {},
    -- stylua: ignore
    keys = {
      { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
      { "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
      { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
      { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
      -- { "#", mode = "n", function() require("flash").jump({pattern = vim.fn.expand("<cword>")}) end, desc = "Flash cword" },
      { "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
    }
  },

  -- dap
  {
    "mfussenegger/nvim-dap-python",
    config = function ()
      require('dap-python').setup('~/.venv/bin/python')
    end
  },

  -- {
  --   "zbirenbaum/copilot-cmp",
  --   event = "InsertEnter",
  --   dependencies = { "zbirenbaum/copilot.lua" },
  --   config = function()
  --     vim.defer_fn(function()
  --       require("copilot").setup() -- https://github.com/zbirenbaum/copilot.lua/blob/master/README.md#setup-and-configuration
  --       require("copilot_cmp").setup() -- https://github.com/zbirenbaum/copilot-cmp/blob/master/README.md#configuration
  --     end, 100)
  --   end,
  -- },
  -- copilot
  -- {
  --   "zbirenbaum/copilot.lua",
  --   cmd = "Copilot",
  --   event = "InsertEnter",
  --   config = function()
  --     require("copilot").setup({
  --       suggestions = { enabled = false },
  --       panel = { enabled = false },
  --     })
  --   end,
  -- },
  -- {
  --   "zbirenbaum/copilot-cmp",
  --   event = "InsertEnter",
  --   dependencies = { "zbirenbaum/copilot.lua" },
  --   config = function()
  --     local ok, cmp = pcall(require, "copilot_cmp")
  --     if ok then cmp.setup({}) end
  --   end,
  -- },


  { "tpope/vim-surround" },

  -- todo
  {
    "folke/todo-comments.nvim",
    event = "BufRead",
    opts = {},
  },

  -- -- 括号
  {
    "p00f/nvim-ts-rainbow",
  },

  -- 跳出括号
  {
    'abecodes/tabout.nvim',
    opts = {
      tabkey = '<C-d>', -- key to trigger tabout, set to an empty string to disable
      backwards_tabkey = '<C-M-d>', -- key to trigger backwards tabout, set to an empty string to disable
      act_as_tab = true, -- shift content if tab out is not possible
      act_as_shift_tab = false, -- reverse shift content if tab out is not possible (if your keyboard/terminal supports <S-Tab>)
      default_tab = '<TAB>', -- shift default action (only at the beginning of a line, otherwise <TAB> is used)
      default_shift_tab = '<S-TAB>', -- reverse shift default action,
      enable_backwards = true, -- well ...
      completion = true, -- if the tabkey is used in a completion pum
      tabouts = {
        {open = "'", close = "'"},
        {open = '"', close = '"'},
        {open = '`', close = '`'},
        {open = '(', close = ')'},
        {open = '[', close = ']'},
        {open = '{', close = '}'}
      },
      ignore_beginning = true, --[[ if the cursor is at the beginning of a filled element it will rather tab out than shift the content ]]
      exclude = {} -- tabout will ignore these filetypes
    },
    dependencies = {
      'nvim-treesitter/nvim-treesitter',
      'hrsh7th/nvim-cmp',
    },
  },

  -- 交互式显示结果
  {
    "metakirby5/codi.vim",
    cmd = "Codi",
  },

  -- 点命令
  { "tpope/vim-repeat" },

  -- gx打开网页
  {
    "felipec/vim-sanegx",
    event = "BufRead",
  },

  -- markdown 预览
  {
    "iamcco/markdown-preview.nvim",
    build = "cd app && npm install",
    ft = "markdown",
    config = function()
      vim.g.mkdp_auto_start = 1
    end,
  },

  -- 虚拟环境
  {
    "linux-cultist/venv-selector.nvim",
    dependencies = {
      "neovim/nvim-lspconfig",
      "nvim-telescope/telescope.nvim",
      "mfussenegger/nvim-dap-python",
      "jose-elias-alvarez/null-ls.nvim",
    },
    opts = {
      -- Your options go here
      name = "python",
      -- auto_refresh = false
      path = "/home/fd/.venv/python",
      parents = 1,
    },
    event = "VeryLazy", -- Optional: needed only if you want to type `:VenvSelect` without a keymapping
    keys = {
      -- Keymap to open VenvSelector to pick a venv.
      { "<leader>vs", "<cmd>VenvSelect<cr>" },
      -- Keymap to retrieve the venv from a cache (the one previously used for the same project directory).
      { "<leader>vc", "<cmd>VenvSelectCached<cr>" },
    }
  },
}

-- vim.api.nvim_create_autocmd("FileType", {
--   desc = "Auto select virtualenv Nvim open",
--   pattern = "python",
--   callback = function()
--     vim.cmd[[VenvSelectCached]]
--   end,
--   once = true,
-- })
